//
//  MybanKHeaderView.m
//  wangzhe
//
//  Created by 李 佳伟 on 2017/10/19.
//  Copyright © 2017年 李 佳伟. All rights reserved.
//

#import "MybanKHeaderView.h"
#import "JTCSM.h"

@interface MybanKHeaderView (){
    UILabel *label;
}

@end
@implementation MybanKHeaderView

/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/

- (id)initWithFrame:(CGRect)frame{
    self = [super initWithFrame:frame];
    
    if (self) {
        self.backgroundColor = [UIColor whiteColor];
        CGFloat width = frame.size.width;
        CGFloat height = frame.size.height;
        
        UIImageView *imageview = [[UIImageView alloc]initWithFrame:CGRectMake(0, 0,width , height*2/3)];
        imageview.image = [UIImage imageNamed:@"bg_banner4@2x.png"];
        [self addSubview:imageview];
        imageview.userInteractionEnabled = YES;
        
        label = [UILabel initWithFrame:CGRectMake(0, 50, KSCREENWidth, 20) text:@"" font:22 textAlignment:NSTextAlignmentCenter texcolor:[UIColor whiteColor] backgroundColor:[UIColor clearColor]];
        [self addSubview:label];
        
        UIButton *button = [[UIButton alloc] init];
        button.frame = CGRectMake(10, 40, 60, 44);
        [button setImage:[UIImage imageNamed:@"return_iv_white.png"] forState:UIControlStateNormal];
        [button setTitle:@"返回" forState:UIControlStateNormal];
        //        image的位置大小调整
        button.imageEdgeInsets = UIEdgeInsetsMake(12.5, 5, 12.5, 40);
        //        title的位置大小调整
        button.titleEdgeInsets = UIEdgeInsetsMake(0, -30, 0, 0);
        [button addTarget:self action:@selector(gotobackVC) forControlEvents:UIControlEventTouchUpInside];
        [self addSubview:button];
        
        UIButton *delegatebutton = [[UIButton alloc] init];
        delegatebutton.frame = CGRectMake(KSCREENWidth-50, 40, 40, 44);
        [delegatebutton setTitle:@"删除" forState:UIControlStateNormal];
        [delegatebutton addTarget:self action:@selector(CreditCarddelete) forControlEvents:UIControlEventTouchUpInside];
        [self addSubview:delegatebutton];

        
        self.doubleLabel = [[MyDoubleLabelView alloc]initWithFrame:CGRectMake(0, 80, width, 0) titleFontsize:18 titlecolor:[UIColor whiteColor] contentFontsize:20 contentcolor:[UIColor whiteColor]];
        [self.doubleLabel setvalueWithModel:@{KDoubleLabelTitle:@"还款金额",KDoubleLabelContent:@"0"}];
        [self addSubview:self.doubleLabel];
        
        
        self.bankview = [[MyBankCardView alloc]initWithFrame:CGRectMake(40, KVIEW_Y(self.doubleLabel)+10, width-80, 0)];
        [self addSubview:self.bankview];
        [df layerWithView:self.bankview radius:3 width:0 color:nil];
        [df setTheViewYiYing:self.bankview shadowColor:RGBACOLOR(241, 241, 241, 1) shadowOffset:CGSizeMake(3, 3) apla:0.5];
        
    }
    
    return self;
}

- (void)setvalueWithMybankCardModel:(MyBankCardModel *)model{
    
    
    self.bankview.bankCardLabel.text = model.bank_name;
    self.bankview.bankNamebLabel.text = model.bank_card;
    self.bankview.dateLabel.text = model.period;
    self.bankview.timeLabel.text = model.cvn2;
    label.text = model.bank_name;
    [self.doubleLabel setvalueWithModel:@{KDoubleLabelTitle:@"还款金额",KDoubleLabelContent:model.current_bill}];

}


- (void)gotobackVC{
    [self.delegate gotoback];
}

- (void)CreditCarddelete{
    [self.delegate shanchu];
}

@end
